<template>
  <el-dialog title="资料修改" :visible.sync="visible" width="800px">
    <el-form :model="form" ref="form" :rules="rules" label-width="120px">
      <el-form-item label="学习证明资料/相关经验证明资料" prop="studyImage">
        <TheUpload
          ref="uploadRefs"
          :files="form['studyImage']"
          :limit="8"
          @upload="(e) => (form['studyImage'] = e.files.map((file) => file.url))"
        />
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">返 回</el-button>
      <el-button type="primary" @click="handleSubmit">保 存</el-button>
    </span>
  </el-dialog>
</template>

<script>
import TheUpload from "@/components/TheUpload";

export default {
  components: { TheUpload },
  props: {
    workerInfo: null
  },
  data() {
    return {
      visible: false,
      form: {
        studyImage: []
      },
      rules: {
        studyImage: [
          // {
          //   type: "array",
          //   required: true,
          //   min: 1,
          //   max: 8,
          //   message: "请上传上传学习证明资料/相关经验证明资料",
          //   trigger: "change"
          // }
        ]
      }
    };
  },
  mounted() {},
  methods: {
    handleSubmit() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.$emit("update", this.form);
        } else {
          console.log("error submit!!", valid);
          return false;
        }
      });
    },
    open() {
      this.visible = true;
      this.$nextTick(()=>{
        this.form.studyImage = this.workerInfo.information.split(',').filter(item=>item)
      })
    },
    close() {
      this.$refs.form.resetFields();
      this.visible = false;
    }
  }
};
</script>

